package com.wavehi.classloader;

/**
 * @Author WaveHi
 * @Date 1/10/2021 下午 7:38
 * @Version 1.0
 * @Contact HJBWaveHi@163.com
 * @Description Demonstrate the use of class loader.
 */
public class ClassLoaderDemo01 {
    public static void main(String[] args) {
        //Get the system class loader
        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
        System.out.println(systemClassLoader);//sun.misc.Launcher$AppClassLoader@dad5dc
        //Get the upper class loader
        ClassLoader parentClassLoader = systemClassLoader.getParent();
        System.out.println(parentClassLoader);//sun.misc.Launcher$ExtClassLoader@a57993
        ClassLoader parentUpClassLoader = parentClassLoader.getParent();
        System.out.println(parentUpClassLoader);//null
        //Get the class loader used to loader current class.
        ClassLoader currentClassLoader = ClassLoaderDemo01.class.getClassLoader();
        System.out.println(currentClassLoader);//sun.misc.Launcher$AppClassLoader@dad5dc
    }
}
